﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Configuration;
using CrystalDecisions.Shared;
using System.Data.Common;
using System.Data.SqlClient;
using Peekaboo2008.util;
using Peekaboo2008.dao;

namespace Peekaboo2008.view
{
    public partial class FormReportViewerHangBanTrongKhoangNgayTheoNhanVien : Form
    {
        public FormReportViewerHangBanTrongKhoangNgayTheoNhanVien()
        {
            InitializeComponent();
        }

        public FormReportViewerHangBanTrongKhoangNgayTheoNhanVien(String chiNhanh, String tuNgay, String denNgay)
        {
            InitializeComponent();
            LoadReport(chiNhanh, tuNgay, denNgay);
        }


        /**/
        // Dua id cua chi nhanh va ngay xem bao cao de load thong tin can xem
        /**/

        public void LoadReport(String chiNhanh, String tuNgay, String denNgay)
        {
            String applicationPath = Application.StartupPath.Replace("\\bin\\Debug", "");
            String pathReport = @"\report\";
            DataTable dataTable = ReportDAO.HangBanTrongKhoangNgayTheoNhanVien(chiNhanh, tuNgay, denNgay);
            if (dataTable.Rows.Count == 0)
            {
                this.Dispose();
            }
            else
            {
                ReportDocument rdmReportDocument = new ReportDocument();
                // load crystal report vao report document
                rdmReportDocument.Load(applicationPath + pathReport + "CrystalReportHangBanTrongKhoangNgayTheoNhanVien.rpt");
                rdmReportDocument.SetDataSource(dataTable);
                crvReportViewer.ReportSource = rdmReportDocument;
                crvReportViewer.Visible = true;
                crvReportViewer.Refresh();
            }
        }

    }
}
